@extends('admin.base')

@section('page_title')
  分配部落
@endsection

@section('sidebar')
  @include('admin.sidebar', ['active' => 'ants.review'])
@endsection

@section('content')
  <section class="content-header">
    <h1>&nbsp;</h1>
    <ol class="breadcrumb">
      <li>用户管理</li>
      <li class="active">分配部落</li>
    </ol>
  </section>
  <section class="content container-fluid">
    <div class="box box-primary">
      <form role="form" method="post" data-fv-addons="i18n" class="form-horizontal">
        {{ csrf_field() }}
        <input type="hidden" name="luo" value="{{ $user->get_luo()?$user->get_luo()->name:'' }}" />
        <div class="box-body">
          <div class="form-group">
            <label class="col-sm-2 control-label">用户名:</label>
            <label class="col-sm-8 control-label" style="text-align:left">{{ $user->name }}</label>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">邮箱:</label>
            <label class="col-sm-8 control-label" style="text-align:left">{{ $user->email }}</label>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">联系方式:</label>
            <label class="col-sm-8 control-label" style="text-align:left">{{ $user->tel }}</label>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">常住地:</label>
            <label class="col-sm-8 control-label" style="text-align:left">{{ get_user_loc($user) }}</label>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">职业:</label>
            <label class="col-sm-8 control-label" style="text-align:left">{{ get_user_job($user) }}</label>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">分配部落:</label>
            <div class="col-sm-8">
              <div class="btn-group pull-left">
                <button class="btn btn-default dropdown-toggle btn-luo" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                  {{ $user->get_luo()? $user->get_luo()->name: '请选择部落' }}
                  <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                  @foreach ($luo_list as $luo)
                    <li><a href="#">{{ $luo->name}}</a></li>
                  @endforeach
                </ul>
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-10 col-sm-offset-1 alert alert-warning">
              为用户分配部落则代表用户审核通过，用户账号会被激活
            </div>
            <div class="col-sm-8 col-sm-offset-2 text-left">
              <button type="submit" class="btn btn-primary">确定</button>
            </div>
          </div>
        </div>
      </form>
    </div>
  </section>
@endsection

@section('page_script')
  <script>
$(function(){
  @isset ($msg)
    alert("{{ $msg }}");
    $('button.btn-primary').remove();
  @endisset

  $('.dropdown-menu li a').on('click', function(e){
    e.preventDefault();
    var luo = $(this).text();
    $('.btn-luo').html(luo + '<span class="caret"></span>');
    $('input[name=luo]').val(luo);
  });
})
  </script>
@endsection
